package inf3791.calendarsystem.others;

import java.util.LinkedList;
import java.util.List;

/**
 * Displays a simple menu.
 *
 * @author Jonas Weber
 */
public class OthersMainMenu extends javax.swing.JPanel {

    public class MainMenuClickedEvent extends java.util.EventObject {

        public MainMenuClickedEvent(Object source) {
            super(source);
        }
    }

    public interface MainMenuClickedListener extends java.util.EventListener {

        public void home(MainMenuClickedEvent evt);

        public void calendar(MainMenuClickedEvent evt);

        public void appointments(MainMenuClickedEvent evt);

        public void addnewevent(MainMenuClickedEvent evt);
    }
    List<MainMenuClickedListener> menulisteners = new LinkedList<>();

    public void addMenuClickedListener(MainMenuClickedListener listener) {
        menulisteners.add(listener);
    }

    public void removeMenuClickedListener(MainMenuClickedListener listener) {
        menulisteners.remove(listener);
    }

    /**
     * Creates new form OthersMainMenu
     */
    public OthersMainMenu() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton3 = new javax.swing.JButton();
        buthome = new javax.swing.JButton();
        butcalendar = new javax.swing.JButton();
        butnewevent = new javax.swing.JButton();

        jButton3.setText("jButton3");

        buthome.setText("Home");
        buthome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buthomeActionPerformed(evt);
            }
        });

        butcalendar.setText("Calendar");
        butcalendar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butcalendarActionPerformed(evt);
            }
        });

        butnewevent.setText("Add New Event");
        butnewevent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butneweventActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(buthome, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(butcalendar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(butnewevent, javax.swing.GroupLayout.DEFAULT_SIZE, 328, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(buthome, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(butcalendar, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(67, 67, 67)
                .addComponent(butnewevent, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void buthomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buthomeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_buthomeActionPerformed

    private void butcalendarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butcalendarActionPerformed
        for (MainMenuClickedListener l : menulisteners) {
            l.calendar(new MainMenuClickedEvent(this));
        }
    }//GEN-LAST:event_butcalendarActionPerformed

    private void butneweventActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butneweventActionPerformed
        for (MainMenuClickedListener l : menulisteners) {
            l.addnewevent(new MainMenuClickedEvent(this));
        }
    }//GEN-LAST:event_butneweventActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton butcalendar;
    private javax.swing.JButton buthome;
    private javax.swing.JButton butnewevent;
    private javax.swing.JButton jButton3;
    // End of variables declaration//GEN-END:variables
}
